package Demo16_30.Test23;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 14229 on 2020/1/29.
 */
public class Test {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
        List<Animal> animals = test01();
        System.out.println(animals);

    }
    public static List<Animal> test01() throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        List<Animal> list = new ArrayList<>();

        List<String> lines = FileUtils.readLines(new File("dataAnimal.txt"));

        for (String line : lines) {
            String[] ss = line.split(" ");
            Class<?> aClass = Class.forName(ss[0]);
            Object o = aClass.newInstance();
            list.add((Animal) o);
        }
        return list;
    }
}
